﻿using System;
using Terraria.Localization;

namespace Terraria.ModLoader.UI
{
	// Token: 0x0200029F RID: 671
	internal class TimeHelper
	{
		// Token: 0x06001AD4 RID: 6868 RVA: 0x0042C570 File Offset: 0x0042A770
		public static string HumanTimeSpanString(DateTime yourDate)
		{
			TimeSpan timeSpan = new TimeSpan(DateTime.UtcNow.Ticks - yourDate.Ticks);
			double num = Math.Abs(timeSpan.TotalSeconds);
			if (num < 60.0)
			{
				if (timeSpan.Seconds != 1)
				{
					return Language.GetTextValue("tModLoader.XSecondsAgo", timeSpan.Seconds);
				}
				return Language.GetTextValue("tModLoader.1SecondAgo");
			}
			else
			{
				if (num < 120.0)
				{
					return Language.GetTextValue("tModLoader.1MinuteAgo");
				}
				if (num < 2700.0)
				{
					return Language.GetTextValue("tModLoader.XMinutesAgo", timeSpan.Minutes);
				}
				if (num < 5400.0)
				{
					return Language.GetTextValue("tModLoader.1HourAgo");
				}
				if (num < 86400.0)
				{
					return Language.GetTextValue("tModLoader.XHoursAgo", timeSpan.Hours);
				}
				if (num < 172800.0)
				{
					return Language.GetTextValue("tModLoader.1DayAgo");
				}
				if (num < 2592000.0)
				{
					return Language.GetTextValue("tModLoader.XDaysAgo", timeSpan.Days);
				}
				if (num < 31104000.0)
				{
					int num2 = Convert.ToInt32(Math.Floor((double)timeSpan.Days / 30.0));
					if (num2 > 1)
					{
						return Language.GetTextValue("tModLoader.XMonthsAgo", num2);
					}
					return Language.GetTextValue("tModLoader.1MonthAgo");
				}
				else
				{
					int num3 = Convert.ToInt32(Math.Floor((double)timeSpan.Days / 365.0));
					if (num3 > 1)
					{
						return Language.GetTextValue("tModLoader.XYearsAgo", num3);
					}
					return Language.GetTextValue("tModLoader.1YearAgo");
				}
			}
		}

		// Token: 0x0400180F RID: 6159
		private const int SECOND = 1;

		// Token: 0x04001810 RID: 6160
		private const int MINUTE = 60;

		// Token: 0x04001811 RID: 6161
		private const int HOUR = 3600;

		// Token: 0x04001812 RID: 6162
		private const int DAY = 86400;

		// Token: 0x04001813 RID: 6163
		private const int MONTH = 2592000;
	}
}
